#pragma once
#include"Hash_2.h"
using namespace std;
namespace dj
{
	template<class K,class T>
	class unorderedMap
	{
		struct MapKeyOfT
		{
			const K &operator()(const pair<const K,T>& kv)
			{
				return kv.first;
			}
		};
	public:
		typedef typename dj::Hash_2<K, pair<const K, T>, MapKeyOfT>::iterator iterator;
		typedef typename dj::Hash_2<K, pair<const K, T>, MapKeyOfT>::const_iterator const_iterator;
		pair<iterator, bool>insert(const pair<const K, T>& kv)
		{
			return _hash.insert(kv);
		}
		iterator begin()
		{
			return _hash.begin();
		}
		iterator end()
		{
			return _hash.end();
		}
		const_iterator begin()const
		{
			return _hash.begin();
		}
		const_iterator end()const
		{
			return _hash.end();
		}
		T& operator[](const K&key)
		{
			pair<iterator,bool>p = insert(make_pair(key, T()));
			return (*(p.first)).second;

		}
	private:
		dj::Hash_2<K, pair<const K, T>, MapKeyOfT>_hash;
	};
}
